<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>计算属性</title>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
			<div>{{reverseMethods()}}</div>
			<div>{{reverseMethods()}}</div>
			<div>{{reverseMethods()}}</div>
			<hr>
			<h3>计算属性</h3>
			<div>{{reverseComputed}}</div>
			<div>{{reverseComputed}}</div>
			<div>{{reverseComputed}}</div>
			<div>{{reverseComputed}}</div>
		</div>
		<script>
			let vm=new Vue({
				el:'#app',
				data:{
					msg:'0123456789',
					num:100
				},
				methods:{
					reverseMethods:function(){
						console.log("reverseMethods call...");
						return this.msg.split('').reverse().join('');
					}
				},
				computed:{  //定义计算属性
					reverseComputed:function(){
						console.log("reverseComputed call...");
						return this.msg.split('').reverse().join('');
					}
				}
			});
		</script>
	</body>
</html>
